﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

using G.Runtime;
using GameLibrary.Model;
using GameLibrary.Model.Enums;

namespace Conquest
{
    public class CityState : Component, HasGameSpace
    {
        private GameSpace _Game;
        
        public CityState()
        {
            GameSpaceDef game = new GameSpaceDef();
            game.Height = 3;
            game.Width = 3;
            _Game = new GameSpace(game);
            
            _Game.Click += delegate(GameClickEventArgs args) 
            {
                if (args.element == null && SelectedElement.GameElement != null)
                {
                    GameElementDef def = new GameElementDef(
                        _Game.GameDef, args.location);
                    GameElement s = SelectedElement.GameElement;
                    def.MoveStratagy = MoveStratagyEnum.UP_LEFT_RIGHT;
                    def.CollisionStratagy = CollisionStratagyEnum.FIGHT;
                    def.Icon = s.Icon;
                    def.Text = s.Text;
                    def.Player = s.Player;
                    _Game.GameDef.GameElementDefs.Add(def);
                    GameElement element = new GameElement(def, _Game);
                    _Game.Elements.Add(element);
                    SelectedElement.GameElement = null;
                }
            };
            
            _Game.Start();
        }
        
        public GameSpace Game
        {
            get { return _Game; }
        }
        
    }
}

